import Vue from 'vue';
import Vuex from 'vuex';


Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        num: 0,
        table:[
            {
                id:0,
                tr1:[1,1,1,1,1,1,1,1,1]
            },
            {
                id:1,
                tr1:[2,2,2,2,2,2,2,2,2]
            },
            {
                id:2,
                tr1:[1,1,1,1,1,1,1,1,1]
            },
            {
                id:3,
                tr1:[1,1,1,1,1,1,1,1,1]
            },
            {
                id:4,
                tr1:[3,3,3,3,3,3,3,3,3]
            },
            {
                id:5,
                tr1:[2,2,2,2,2,2,2,2,2]
            },
        ],
        arr: []
    },
    getters: {

    },
    mutations: {
        addCount(state) {
            state.num++
        },
        subCount(state) {
            state.num--
        },
        serch(state,a){
            // console.log(a);
            state.arr = []
            for(var i=0;i<state.table.length;i++){
                if(a==state.table[i].tr1[1]){
                    state.arr.push(state.table[i])
                }
                
            }

        }
    },
    actions: {
        a_addCount({state,commit}) {
            commit('addCount')
            // console.log(state);
        }
    },
    modules: {

    }
})